home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / replymsg.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  102 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: replymsg.c,v 1.4 1996/08/13 13:56:08 digulla Exp $
  4.     $Log: replymsg.c,v $
  5.     Revision 1.4  1996/08/13 13:56:08  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:18  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "exec_intern.h"
  17. #include <aros/libcall.h>
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <exec/ports.h>
  23.     #include <clib/exec_protos.h>
  24.  
  25.     __AROS_LH1(void, ReplyMsg,
  26.  
  27. /*  SYNOPSIS */
  28.     __AROS_LHA(struct Message *, message, A1),
  29.  
  30. /*  LOCATION */
  31.     struct ExecBase *, SysBase, 63, Exec)
  32.  
  33. /*  FUNCTION
  34.     Send a message back to where it came from. It's generally not
  35.     wise to access the fields of a message after it has been replied.
  36.  
  37.     INPUTS
  38.     message - a message got with GetMsg().
  39.  
  40.     RESULT
  41.  
  42.     NOTES
  43.  
  44.     EXAMPLE
  45.  
  46.     BUGS
  47.  
  48.     SEE ALSO
  49.     WaitPort(), GetMsg(), PutMsg()
  50.  
  51.     INTERNALS
  52.  
  53.     HISTORY
  54.  
  55. ******************************************************************************/
  56. {
  57.     __AROS_FUNC_INIT
  58.  
  59.     struct MsgPort *port;
  60.  
  61.     /* Protect the message against access by other tasks. */
  62.     Disable();
  63.  
  64.     /* Get replyport */
  65.     port=message->mn_ReplyPort;
  66.  
  67.     /* Not set? Only mark the message as no longer sent. */
  68.     if(port==NULL)
  69.     message->mn_Node.ln_Type=NT_FREEMSG;
  70.     else
  71.     {
  72.     /* Mark the message as replied */
  73.     message->mn_Node.ln_Type=NT_REPLYMSG;
  74.  
  75.     /* Add it to the replyport's list */
  76.     AddTail(&port->mp_MsgList,&message->mn_Node);
  77.  
  78.     /* And trigger the arrival action. */
  79.     switch(port->mp_Flags&PF_ACTION)
  80.     {
  81.         case PA_SIGNAL:
  82.         /* Send a signal */
  83.         Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
  84.         break;
  85.  
  86.         case PA_SOFTINT:
  87.         /* Raise a software interrupt */
  88.         Cause((struct Interrupt *)port->mp_SoftInt);
  89.         break;
  90.  
  91.         case PA_IGNORE:
  92.         /* Do nothing */
  93.         break;
  94.     }
  95.     }
  96.  
  97.     /* All done */
  98.     Enable();
  99.     __AROS_FUNC_EXIT
  100. }
  101.  
  102.